//天龙八部 js
var requrl = $request.url;
var uuid = '';
var newbody = '{"info":1,"data":{"accname":"710697a3add0fd56a10dff61e97947b0","third_accname":"","php_token":"21d0d7a3dc44b22f3258ce78b7997d03","game":"tlbbrybwx","platform":"wechat","uid":"710697a3add0fd56a10dff61e97947b0","user_name":"oPk_15J9h16kVUSRH0LRUhqDlTyQ","identify":0,"visitor":false,"session":"YXCVEAfKlIA+Cql+qDMa0g==","open_id":"oPk_15J9h16kVUSRH0LRUhqDlTyQ","device_id":"710697a3add0fd56a10dff61e97947b0","acc_type":1,"real_acc":0,"last_is_test":1,"last_info":{"last_war":"\u71d5\u5f52","last_sid":"80505"},"isSuperAccount":0,"isSuperAccountTest":0},"msg":"success"}';


if(requrl == 'https://api-wxhg.chuxinhd.com/vt/api_verify_v2.php'){
 
    var rsp = JSON.parse(newbody);
    uuid = rsp['data']['open_id'];
    var erweima = 'https://api.qrserver.com/v1/create-qr-code/?size=150x150&data='+'https://paycenter.chuxinhudong.com/v1/web/nowPayWeb/tlbbrybwx/wechat/wx7c6587fcbdf80d21/'+uuid;

    var newurl2 = "https://api.day.app/push";
    var header = {'Content-Type': 'application/json; charset=utf-8'};
    var tzjson = {"title": 'tlbb',"body": erweima,"device_key": "q74cfGrYxMokGQ9JnmTo63","badge": 1,"sound": "birdsong.caf","icon": "https://day.app/assets/images/avatar.jpg"};
    
    var newbodybark = JSON.stringify(tzjson);

    let params = {
        url: newurl2,
        headers: header,
        body: newbodybark, 
    }
    $httpClient.post(params, function(error, response, data) {})
    $done({body:newbody})
}

if(requrl.startsWith('https://paycenter.chuxinhudong.com/v1/web/nowPayWeb/tlbbrybwx/wechat/wx7c6587fcbdf80d21/')){
 
    var rsp = JSON.parse(newbody);
    uuid = rsp['data']['open_id'];
    var tp = 'https://paycenter.chuxinhudong.com/v1/web/nowPayWeb/tlbbrybwx/wechat/wx7c6587fcbdf80d21/'+uuid;
    var erweima = 'https://api.qrserver.com/v1/create-qr-code/?size=150x150&data='+tp;

    // var rspheader = $response.headers;
    // rspheader['Location'] = location;
    // rspheader['Status Code'] = '302';
    // $done({headers:rspheader})

    // var html = '<!DOCTYPE html><html><head><meta charset="utf-8" /><title></title></head><body><img src="'+erweima+'" /></body></html>';
    
    var html = tp;
    
    $done({body:html})

    // let params = {
	//     url: erweima,
	//     headers: {
	// 	    'Accept': "text/html",
    //         'Content-Type': "application/json"
	//     },
	//     body: {
	//     	'app': "tlbb"
	//     }, 
    // }
    // $httpClient.get(params, function(error, response, data) {
    //     $done({body:data})
    // })

}

//$done({})